{% extends "base.html" %}

{% block title %}PSES Assets{% endblock %}

{% block app %}PSES Asset Tree{% endblock %}
{% load mptt_tags %}
{% block content %}
<ul>
	{% recursetree nodes %}
		<li> {# {% regroup node by node.flagText as nodes %} #}
			<p>{{ node.itemID }} : {{ node.typeName }} - {{ node.quantity }} | level : {{ node.level }} | parent: {{ node.parentID.itemID }} </p>
			
			{# {{ node.flagText.grouper }} #}
			<p> location : {{ node.locationName }} - flag : {{ node.flagText }} </p> 
			{% if not node.is_leaf_node %}
				<ul class="children">
					{{ children }}
				</ul>
			{% endif %}
		</li>
	{% endrecursetree %}
</ul>
{% comment %}
<p> Items test </p>
<ul>
	{% recursetree items %}
		<li>
			{{ node }} - {{ node.quantity }}
			{% if not node.is_leaf_node %}
			<ul>
				{% regroup items by item.level as node.get_descendants %}
					
						{% for item in node.get_descendants %}
							{{ item.level.grouper }}
							{% ifchanged item.parent %}
						 		<ul>
						 			<li>{{ item }}</li>
						 		</ul>
						 	{% else %}
						 		<li>
						 			{{ item }} ==> {{ item.level }}
						 		</li>
							{% endifchanged %}
						{% comment %}
						{% if item.level > 1 %}
							<li>
							{{ item  }} - {{ item.level }} / {{ item.lft }}
							</li>
						{% else %}
							<li class='children'>
								{{ item }}
							</li>
					{% endif %} 
			
			{% endfor %}
			</ul>
		{% endif %}
 	</li>
	{% endrecursetree %}
</ul>
{% endcomment %}
{% endblock %}